﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Xml.Serialization;
using System.IO;
using System.Windows.Forms;

namespace intelliSys.NankaiUtilities.EventSynchronizer
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App : System.Windows.Application
    {
        Mutex mutex;
        public static NotifyIcon trayIcon;
        private void Application_Startup_1(object sender, StartupEventArgs e)
        {
            bool createdNew;
            mutex = new Mutex(true, "intelliSys_NankaiUtilities_EventSynchronizer", out createdNew);
            if (createdNew == false)
            {
                System.Windows.Application.Current.Shutdown(0);
            }
            Setting.Default.PropertyChanged += Default_PropertyChanged;
            Thread.CurrentThread.Name = "STA";
        }


        void Default_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            Setting.Default.Save();
        }

        private void Application_Exit_1(object sender, ExitEventArgs e)
        {
            mutex.Dispose();
        }
    }
}
